const Db = require('../db/Db')

class MenuModel {
  // 添加菜单
  async insertMenu(tableName, data) {
    const res = await Db.insert(tableName, data);
    return res;
  }
  // 修改菜单
  async update(tableName, data, whereJson) {
    const res = await Db.update(tableName, data, whereJson);
    return res;
  }
  // 删除菜单
  async deleteMenu(tableName, data) {
    const res = await Db.delete(tableName, data);
    return res;
  }
  // 查询单个菜单信息
  async getOneMenu(tableName, data) {
    const res = await Db.find(tableName, data);
    return res;
  }
  // 查询左侧菜单信息
  async getMenuInfo(sql) {
    const res = await Db.query(sql);
    return res;
  }
  // 查询菜单树
  async getMenuWhere(sql) {
    const res = await Db.query(sql);
    return res;
  }
}

module.exports = new MenuModel()